package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.MallRefundsDO;
import com.starlink.model.request.MallRefundsRequest;
import com.starlink.model.request.mall.AdminRefundRequest;
import com.starlink.model.request.mall.MallCancelOrderRequest;
import com.starlink.model.vo.mall.AdminRefundsVO;
import com.starlink.model.vo.mall.WechatRefundsVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface MallRefundsMapper extends BaseMapper<MallRefundsDO> {
    MallRefundsDO selectDOById(Long id);
    List<MallRefundsDO> selectDOList(MallRefundsDO mallRefunds);
    int insertDO(MallRefundsDO mallRefunds);
    int batchInsertDO(List<MallRefundsDO> mallRefundsDOList);
    int updateDO(MallRefundsDO mallRefunds);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from mall_refunds",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") MallRefundsRequest param);
    @Select({"<script>",
            "   select * from mall_refunds",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<MallRefundsDO> pageQuery(@Param("param") MallRefundsRequest param, @Param("limit") int limit, @Param("offset") long offset);

    Integer selectStatus(@Param("orderId") Long orderId);

    MallRefundsDO selectByOrderId(@Param("orderId")Long orderId);

    void deletedByOrderId(@Param("orderId")Long orderId);

    List<AdminRefundsVO> pageList(AdminRefundRequest request);

    WechatRefundsVO selectRefundOrderDetail(MallCancelOrderRequest request);

    void updateByOrderId(MallRefundsDO refundsDO);

    Long selectIdByOrderId(@Param("orderId") Long orderId);
}
